namespace MoreLinq.Test;

using System.Collections;
using System.Collections.Generic;

/// <summary>
/// This class implement <see cref="IReadOnlyList{T}"/> but specifically prohibits enumeration using GetEnumerator().
/// It is provided to assist in testing extension methods that MUST NOT call the GetEnumerator()
/// method of <see cref="IEnumerable"/> - either because they should be using the indexer or because they are
/// expected to be lazily evaluated.
/// </summary>

sealed class BreakingReadOnlyList<T>(IReadOnlyList<T> list) :
    BreakingReadOnlyCollection<T>(list),
    IReadOnlyList<T>
{
    readonly IReadOnlyList<T> list = list;

    public BreakingReadOnlyList(params T[] values) : this((IReadOnlyList<T>)values) { }

    public T this[int index] => this.list[index];
}
